package com.dmooo.ymx.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.dmooo.ymx.R;
import com.dmooo.ymx.bean.MessageCenterBean;
import com.dmooo.ymx.config.Constants;

import java.util.List;

public class HealthAdapter  extends RecyclerView.Adapter <HealthAdapter.MyHolder>{
    Context context;
    private List<MessageCenterBean.MessageCenterChildBean> list;

    public HealthAdapter(Context context, List<MessageCenterBean.MessageCenterChildBean> list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public MyHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from (parent.getContext ()).inflate (R.layout.ac_health_itemimg,parent,false);
        MyHolder holder = new MyHolder (view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull MyHolder holder, int position) {
        MessageCenterBean.MessageCenterChildBean item = list.get (position);
        Glide.with (context).load (Constants.APP_IP+item.getImg()).into (holder.imageView1);
        holder.content_tv.setText (item.getTitle ());

    }

    @Override
    public int getItemCount() {
        return list.size ();
    }

    class MyHolder extends RecyclerView.ViewHolder {
        ImageView imageView1;
        TextView content_tv;
        public MyHolder(View itemView) {
            super (itemView);
            imageView1 = itemView.findViewById (R.id.imageView1);
            content_tv = itemView.findViewById (R.id.content_tv);

        }
    }
}
